import { topCategory } from '@/api/constants'
import { createRouter, createWebHashHistory } from 'vue-router'

const Layout = () =>
    import ('@/views/layout')
const Home = () =>
    import ('@/views/home')
const TopCategory = () =>
    import ('@/views/category/index')
const SubCategory = () =>
    import ('@/views/category/sub')
const routes = [
        //一级路由布局容器
        {
            path: '/',
            component: Layout,
            children: [{
                path: '/',
                component: Home
            }, {
                path: '/category/:id',
                component: TopCategory
            }, {
                path: '/category/sub/:id',
                component: SubCategory
            }]
        }
    ]
    //创建一个路由实例
const router = createRouter({
    //使用hash方式实现路由
    history: createWebHashHistory(),
    //配置路由规则
    routes
})

export default router